package day2;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
import jdk.nashorn.internal.ir.CatchNode;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

//新版try-catch 实现文件复制
public class TestCopy2 {
    //try(){}catch{}
    //可以将需要关闭资源的内容放入()编写 会自动关闭
    public static void main(String[] args) {
        try(FileInputStream fis=new FileInputStream("d://io//target.txt");
                FileOutputStream fos=new FileOutputStream("d://io//movie//new1target.txt")
        ){
            long start=System.currentTimeMillis();
            byte[] bs=new byte[1024];
            int len=0;
            while((len= fis.read(bs))!=-1){
                fos.write(bs,0,len);
            }
            long end=System.currentTimeMillis();
            System.out.println("复制成功后："+(end-start)+"ms");
        }catch(IOException e){
            e.printStackTrace();
        }
    }

}
